package com.roncoo.ysq.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.roncoo.ysq.entity.HomePrecinct;
import com.roncoo.ysq.service.IHomePrecinctService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author yuanshuaiqiang
 * @since 2021-03-23
 */
@Api("专区管理")
@RestController
@RequestMapping("/home-precinct")
public class HomePrecinctController {

    @Resource
    private IHomePrecinctService homePrecinctService;
    /**
     * 查询方法
     */
    @ApiOperation("查询所有数据，包括分页，模糊查询")
    @GetMapping("findAll")
    public IPage<HomePrecinct> findAll(Page page,HomePrecinct homePrecinct){
        IPage<HomePrecinct> iPage=homePrecinctService.findAll(page,homePrecinct);
        return iPage;
    }
    /**
     * 添加数据
     */
    @ApiOperation("根据传回的对象来进行添加")
    @PostMapping("addData")
    public Boolean adddata(HomePrecinct homePrecinct){
//        System.out.println(homePrecinct+"=====");
        return homePrecinctService.save(homePrecinct);
    }
    /**
     * 删除方法
     */
    @ApiOperation("根据传回的pid删除数据")
    @GetMapping("del/{pid}")
    public Boolean del(@PathVariable("pid") Integer pid){
        return homePrecinctService.removeById(pid);
    }
    /**
     * 修改
     */
    @ApiOperation("根据传回的对象里的id进行修改")
    @PostMapping("updData")
    public Boolean upddata(HomePrecinct homePrecinct){
        return homePrecinctService.updateById(homePrecinct);
    }
}

